package com.hooya.fa.eu.biz.dao.repository.impl;

import com.hooya.fa.eu.biz.dao.entity.PlInvoiceRecord;
import com.hooya.fa.eu.biz.dao.mapper.PlInvoiceRecordMapper;
import com.hooya.fa.eu.biz.dao.repository.PlInvoiceRecordRepository;
import com.hooya.fa.eu.biz.dao.wrapper.PlInvoiceRecordWrapper;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @Description 1
 * @Author : Zongz
 * @Copyright Copyright (c) 豪雅集团
 * @Create 2023/12/6
 * @Version 1.0.0
 */
@Slf4j
@Repository
@AllArgsConstructor
public class PlInvoiceRecordRepositoryImpl implements PlInvoiceRecordRepository {

    private final PlInvoiceRecordMapper plInvoiceRecordMapper;

    @Override
    public List<PlInvoiceRecord> getListByInvoiceIds(List<String> invoiceIds) {
        return plInvoiceRecordMapper.selectList(PlInvoiceRecordWrapper.newQuery().inInvoiceIds(invoiceIds));
    }

    @Override
    public int batchUpdate(List<PlInvoiceRecord> updateData) {
        AtomicInteger ai = new AtomicInteger(0);
        for (PlInvoiceRecord record : updateData) {
            plInvoiceRecordMapper.updateById(record);
            ai.incrementAndGet();
        }
        return ai.get();
    }

    @Override
    public List<PlInvoiceRecord> getList() {
        return plInvoiceRecordMapper.selectList(null);
    }
}
